﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Text;
using System.Threading.Tasks;
using FazaDemo.BL.InterfaceDomain;
using FazaDemo.BL.Services_;
using FazaDemo.BL.SubDomains;
using FazaDemo.BL.Services_;

namespace FazaDemo.BL.AppFacade
{
    public class MenuReceiver : IMenuReceiver
    {

        private readonly IMenuSetter _loader;

        public MenuReceiver()
        {
            _loader = new MenuSetter();
        }

        public IEnumerable<Menu_Item> GetMenuItems()
        {
            var client = new HttpClient { BaseAddress = new Uri("http://172.19.195.10:8380") };
            client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
            try
            {
                HttpResponseMessage response = client.GetAsync("/api/menuitem/").Result;
                response.EnsureSuccessStatusCode();
                return response.Content.ReadAsAsync<IEnumerable<Menu_Item>>().Result;
            }
            catch (Exception)
            {
                return null;
            }
        }

    }
}
